set matsize 11000

ta wave_number, g(w)

foreach var of varlist agri_ih2010 pasture_ih2010  {
	gen `var'_w1=`var'*w1
	gen `var'_w2=`var'*w2
	gen `var'_w3=`var'*w3
} 

global macroINT "agri_ih2010_w1 agri_ih2010_w2 agri_ih2010_w3 pasture_ih2010_w1 pasture_ih2010_w2 pasture_ih2010_w3"
global fe "i.cty w1 w2 w3"


capture program drop ineffect
program define ineffect, rclass
	version 14.2
	syntax varlist [if] [in] 
	sureg (safe2 pkoarmed $macroINT $micro $fe) /*
	*/ (noincreasevio pkoarmed $macroINT $micro $fe) /*
	*/ (employed pkoarmed $macroINT $micro $fe) /*
	*/ (market_time pkoarmed $macroINT $micro $fe) /*
	*/ (lifesat pkoarmed $macroINT $micro $fe) /*
	*/ (livcondfut pkoarmed $macroINT $micro $fe) /*
	*/ (`varlist' pkoarmed safe2 noincreasevio employed market_time lifesat livcondfut $macroINT $micro $fe) `if' `in'
	return scalar indsafe2  = [safe2]_b[pkoarmed]*[`varlist']_b[safe2]
	return scalar indnovio = [noincreasevio]_b[pkoarmed]*[`varlist']_b[noincreasevio]  
	return scalar indemployed = [employed]_b[pkoarmed]*[`varlist']_b[employed]
	return scalar indmarkt = [market_time]_b[pkoarmed]*[`varlist']_b[market_time]
	return scalar indlifesat = [lifesat]_b[pkoarmed]*[`varlist']_b[lifesat]  
	return scalar indlivcond = [livcondfut]_b[pkoarmed]*[`varlist']_b[livcondfut]  
	return scalar indtotal = [safe2]_b[pkoarmed]*[`varlist']_b[safe2] +/*
		*/		[noincreasevio]_b[pkoarmed]*[`varlist']_b[noincreasevio]  + /*
		*/ 		[employed]_b[pkoarmed]*[`varlist']_b[employed] + /*
		*/		[market_time]_b[pkoarmed]*[`varlist']_b[market_time] + /*
		*/ 		[lifesat]_b[pkoarmed]*[`varlist']_b[lifesat] + /*
		*/		[livcondfut]_b[pkoarmed]*[`varlist']_b[livcondfut]
end

* bootstrapped standard errors bias-corrected
foreach outcome of global outcome {
	bootstrap r(indsafe2) r(indnovio) r(indemployed) r(indmarkt) r(indlifesat) /*
		*/ r(indlivcond) r(indtotal), bca reps(500) seed(1234): ineffect `outcome'
	estat boot, percentile bc bca
}


drop w1 w2 w3 w4 *_w1 *_w2 *_w3
